<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="/misc/css/base.css"  />
<link rel="stylesheet" type="text/css" href="/misc/css/btnicon.css"  />
<link rel="stylesheet" type="text/css" href="/misc/css/reset_admin.css"  />
<link rel="stylesheet" type="text/css" href="/misc/css/adminmenu.css"  />
<link rel="stylesheet" type="text/css" href="/misc/css/newadmin.css"  />
<script type="text/javascript" src="/misc/vendors/jquery/jquery_1.2.6.js"></script>
<script type="text/javascript" src="/misc/vendors/o2js/o2js.js"></script>
<script type="text/javascript" src="/misc/vendors/o2js/o2js_build.js"></script>
<script type="text/javascript" >
var baseUrl = "<?=$themeUrl?>";
$().ready(function(){



});
var grids;
</script>


<title></title> 
<style type="text/css">

/* reset.css */
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td {
margin:0;padding:0;}
table {
border-collapse:collapse;border-spacing:0;}
fieldset,img{
border:0;}
address,caption,cite,code,dfn,em,strong,th,var {
font-style:normal;font-weight:normal;}
ol,ul {
list-style:none;}
caption,th {
text-align:left;}
q:before,q:after {
content:'';}
abbr,acronym {
 border:0;}
html,body{
font-size:12px;font-family:"宋体",Arial,Helvetica,sans-serif;}
/* 整体效果 */
body{
background-color:#FCFCFC;
 
}





/* 菜品套餐加载表格 */
#tbnobody{
display:none;
text-align:center;
}
#tbloading{
display:none;
text-align:center;
}
#tbdata{
margin:20px auto;
display:none;
}


table.goodstb{
width:100%;
border-collapse:collapse;
margin-bottom:20px;
font-size:12px;
color:#555;
}
table.goodstb tr{
border:1px solid #eee;
}
table.goodstb td.goodstb_td{
text-align:left;
vertical-align:top; 
padding:15px;
background-color:#FcFcFc;
} 
table.goodstb td.goodstb_td_l{
width:80%;
}
table.goodstb td.goodstb_td_r{
width:20%;
text-align:center
}
div.goods_title{
font-size:14px;
font-weight:bold;
margin-bottom:10px;
}
div.goods_content{
font-size:14px;
margin-bottom:10px;
color:#666666;
}
div.goods_vege{
margin:10px auto;
position:relative;
}
div.vegeitem{
float:left;
border:1px dashed #CCCCCC;
padding:5px 10px;
margin-right:10px;
margin-bottom:10px;
color:#006600
}


div.goods_edate{
margin:10px auto;
color:#333333;
}



div.goods_alert{
margin:20px auto;
}
div.goods_alert span{
 
}


div.goods_price{
font-size:16px;
font-weight:bold;
margin:20px auto;
color:#FF6666;
}
div.goods_btn{
margin:10px auto;
}

</style>
</head>
<body> 
<div style="margin:5px 20px;"> 
	搜索：
	<select id="publishs" class="textBox" onchange="fnSearchs()">
		<option value="">-- 所有发布状态 --</option>
		<option value="1" selected="selected">发布状态</option>
		<option value="0">暂停状态</option>
	</select>
	<select id="isend" class="textBox" onchange="fnSearchs()">
		<option value="" selected="selected">-- 所有过期状态 --</option>
		<option value="0">未过期</option>
		<option value="1">已过期</option>
	</select>
	<input type="text" maxlength="12" id="keywords" class="searchs" /> 
	<input type="button"  onclick="fnSearchs()" value="查询"  />  	
</div>
<div style="margin:20px;"> 
 	<div class="margin10">
		<div id="tbnobody">
			暂无
		</div>
		<div id="tbloading">
			<img src="/misc/images/account/loading.gif" title="正在加载" />
		</div>
		<div id="tbdata">
			<div style="margin:10px auto;color:#666666;" >
				固定套餐
			</div>
			<div id="tbdata_gd">
				
			</div>
			<div style="margin:10px auto;color:#666666;" >
				组合套餐
			</div>
			<div id="tbdata_zh">
				
			</div>
		</div>	
	</div>
	<div id="grids" style="display:none"></div>
	<div style="height:10px;"></div>
</div>

<script type="text/javascript">


var url_list = '/selection/vegecombo_byadmin';
var funcname = "<?=$funcname?>";  //回调函数   
var grids;//表格对象
var key = '';//缓存关键字 
var results;//缓存的数据 
 

        




$().ready(function(){
	o2js.build('o2grid');
	o2js.build('ymprompt');
	/* 组装表格 */	
	grids = new o2Grid({
		bind:'grids', 
		url:url_list,
		imgpath:'/misc/vendors/o2js/o2grid/image',
		rowNum:1000,
		cols:[
		],
		beforefunc:function(){
			$('#tbdata').hide(); 
			$('#tbnobody').hide(); 
			$('#tbloading').show();
		},
		runfunc:function(obj){
			var details = obj.results; 
			if(details.length == 0){
				$('#tbdata').hide();
				$('#tbloading').hide();
				$('#tbnobody').show();
			}else{
				$('#tbloading').hide();
				$('#tbnobody').hide();
				$('#tbdata').show();
			}
			fnZuZhuangData(details);
		}
	});
	fnSearchs();	 
	$('#keywords').keypress(function(e){
		if(e.keyCode==13||e.keyCode==10){
			fnSearchs();
		}
	}); 
});
function fnSearchs(){
	grids.setBaseParams({
		keywords:encodeURIComponent($('#keywords').val()),
		isend:$('#isend').val(),
		publishs:$('#publishs').val()
	}); 
	grids.load(1); 
}
 


/* 显示数据 */
function fnZuZhuangData(allrs){
	results = allrs;
	var html_gd = '';
	var html_zh = '';
	for(var i=0; i<allrs.length; i++){
		var html='';
		var obj = allrs[i]; 
		html += '	<table class="goodstb">';
		html += '		<Tr>';
		html += '			<td class="goodstb_td goodstb_td_l">';
		html += '				<div class="goods_title">';
		html += obj.name;
		html += '				</div>';
		html += '				<div class="goods_content">';
		html += obj.remark; 
		html += '				</div>';
		html += '				<div class="goods_vege">';
		for(var k=0; k<obj.combo_item.length; k++){
			var citem = obj.combo_item[k];
			html += '					<div class="vegeitem">';
			html += citem.vege_name;
			if(obj.type=='0'){
				html += '						<span>'+citem.vege_num+' 份</span>';
			}
			html += '					</div>';
		}
		html += '					<div class="clear"></div>';
		html += '				</div>';
		html += '			<div class="goods_edate">';
		html += '可配送时间： <span>'+obj.sendbdate+'</span> 至 <span>'+obj.sendedate+'</span>';
		html += '			</div>';
		html += '			</td>';
		html += '			<td class="goodstb_td goodstb_td_r">';
		if(obj.type=='0'){
			html += '				<div class="goods_price">';
			html += '￥'+obj.price; 
			html += '				</div>';
		}else{
			html += '				<div class="goods_alert">';
			html += '最少选菜<span class="red">'+obj.min_num+'份</span> <span class=" ">或</span> <span class="red">'+obj.min_price+'元</span>';
			html += '				</div>';
		}
		html += '				<div class="goods_btn">';
		if(obj.type=='0'){
			html += '					<button class="btn_red" onclick="fnBuy('+obj.id+',\''+obj.name+'\')">确定选择</button>';
		}else{
			html += '					<button class="btn_red"  onclick="fnBuySlt('+obj.id+')">选菜</button>';
		}
		html += '				</div>';
		html += '			</td>';
		html += '		</Tr>';
		html += '	</table>	';	
		if(obj.type=='0'){
			html_gd += html;
		}else{
			html_zh += html;
		}
	}					
	$('#tbdata_gd').html(html_gd);
	$('#tbdata_zh').html(html_zh);
}

 

/* 固定套餐选择 */
function fnBuy(id,name){
	var robj = {
		combo_type:'0',
		combo_id:id,
		combo_name:name
	};
	if(funcname != ''){
		eval('parent.'+funcname+'(robj);');
	}
	if(typeof parent.ymPrompt == 'object'){
		parent.ymPrompt.close();
	}else{
		window.close();
	}	
}

/* 选菜购买 */
function fnBuySlt(id){
	ymPrompt.close();
	ymPrompt.win({
		title:'选菜购买',
		fixPosition:true,
		maxBtn:true,
		width: 600, 
		height: 450,
		iframe:{
			src:'/selection/vegecombo_sltbuy?id='+id+'&funcname=fnBuySltEnd'
		}
	});
}
function fnBuySltEnd(ok){
	var robj = {
		combo_type:'1',
		combo_id:ok.combo_id,
		combo_name:ok.combo_name,
		combo_sendbdate:ok.combo_sendbdate,
		combo_sendedate:ok.combo_sendedate,
		veges:ok.veges
	};
	if(funcname != ''){
		eval('parent.'+funcname+'(robj);');
	}
	if(typeof parent.ymPrompt == 'object'){
		parent.ymPrompt.close();
	}else{
		window.close();
	}	
}
 
</script>
</body>
</html>